import junit.framework.TestCase;
import de.unibi.comet.util.LogSpace;


public class LogSpaceTest extends TestCase {

	public void testLogAdd() {
		double x0=Math.log(0.0);
		double x1=Math.log(1.0);
		double x2=Math.log(70.0);
		assertEquals(Double.NEGATIVE_INFINITY, LogSpace.logAdd(x0, x0));
		assertEquals(Math.log(71.0), LogSpace.logAdd(x1, x2), 1e-12);
		assertEquals(Math.log(71.0), LogSpace.logAdd(x2, x1), 1e-12);
	}

	public void testLogSub() {
		double x0=Math.log(0.0);
		double x1=Math.log(1.0);
		double x2=Math.log(70.0);
		assertEquals(Double.NEGATIVE_INFINITY, LogSpace.logSub(x0, x0));
		assertEquals(Double.NaN, LogSpace.logSub(x1, x2));
		assertEquals(Math.log(69.0), LogSpace.logSub(x2, x1), 1e-12);
	}

}
